﻿using System.Windows;
using compshop.Infrastructure.CompShopDataService;
using compshop.Modules.ClientOrderList.Presenter;

namespace compshop.Modules.ClientOrderList.Views
{
    /// <summary>
    /// Логика взаимодействия для NewClientOrderDialog.xaml
    /// </summary>
    public partial class NewClientOrderDialog : Window
    {
        private ClientOrderListPresenter Presenter;

        public ClientOrder ClientOrder { set; get; }
        
        public NewClientOrderDialog()
        {
            InitializeComponent();
        }

        public NewClientOrderDialog(ClientOrderListPresenter presenter): this()
        {
            Presenter = presenter;
            DataContext = Presenter;
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            ClientOrder = new ClientOrder();
            ClientOrder.ClientFirstName = tbFirstName.Text;
            ClientOrder.ClientLastName = tbLastName.Text;
            ClientOrder.ClientPhone = tbPhone.Text;
            ClientOrder.DepartmentID = (cbDepartment.SelectedItem as Department).DepartmentID;
            DialogResult = true;
            Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }
    }
}
